<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>layui后台管理</title> 
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> 
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">  
<link rel="stylesheet" href="/Public/admin/layui/css/layui.css"  media="all">
<link rel="stylesheet" href="/Public/admin/css/global.css">
<script type="text/javascript" src="/Public/admin/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="/Public/admin/layer/layer.js"></script>
<script type="text/javascript" src="/Public/admin/layui/layui.js"></script>









</head>
<body class="layui-layout-body" style="width:98%; margin:0px auto;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
	<legend>修改文章</legend>
</fieldset>
<div id="addPostBox">
	<div class="layui-form-item">
		<label class="layui-form-label">文章标题</label>
		<div class="layui-input-block">
		<input type="text" name="title" value="<?php echo ($field["title"]); ?>" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">文章关键词</label>
		<div class="layui-input-block">
		<input type="text" name="keywords" value="<?php echo ($field["keywords"]); ?>" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label">文章描述</label>
		<div class="layui-input-block">
			<textarea name="description" class="layui-textarea"><?php echo ($field["description"]); ?></textarea>
		</div>
	</div>
	<div class="layui-form-item layui-form-text">
		<label class="layui-form-label">文章正文</label>
		<div class="layui-input-block" style="height:325px;">
			<textarea id="demo" name="article" class="layui-textarea"><?php echo ($field["article"]); ?></textarea>
		</div>
	</div>
	<div style="width: 216px; margin-left: 110px;"> 
      	<button class="layui-btn layui-btn-fluid" id="addPost">提交</button>
    </div>
</div>
<script>
var addUrl = "<?php echo U('Index/edit');?>"; 
layui.use('layedit', function(){
	var layedit = layui.layedit;
	var index = layedit.build('demo');	
	$("#addPost").click(function(){
		var id = <?php echo ($field["id"]); ?>;
		var title = $("div#addPostBox").find("input[name='title']").val(); 
		var keywords = $("div#addPostBox").find("input[name='keywords']").val(); 
		var description = $("div#addPostBox").find("textarea[name='description']").val(); 
		var article = layedit.getContent(index);
		if(title == "" || title == null){
			layer.alert("文章标题不能为空!");
			return false;
		};
		if(keywords == "" || keywords == null){
			layer.alert("文章关键词不能为空!");
			return false;
		};
		if(description == "" || description == null){
			layer.alert("文章描述不能为空!");
			return false;
		};
		if(article == "" || article == null){
			layer.alert("文章正文不能为空!");
			return false;
		};
		$.post(addUrl,{id:id,title:title,keywords:keywords,description:description,article:article},function(res){
			if(res.code == 1){
				layer.alert(res.msg);
			}else{
				layer.alert(res.msg);
			}; 
		},'json');
	});
});
</script>
</body>
</html>